package com.nix.control;

import com.nix.maze.Map;
import com.nix.role.HistoryRecord;
import com.nix.role.Role;
import org.junit.jupiter.api.Test;

import java.util.Scanner;

/**
 * @author zhangpei
 * @Email zhangpe0312@qq.com
 * @day 2017/12/4 09:30
 * @Use
 */
public class Terminal {
    public static Map initRun(int row, int lie) {
        Map map = null;
        try {
            map = new Map(row, lie);
            map.createMap();
            //设置地图中的道具
            Map.setLatticeValue(map,1,Map.MONSTER);
            Map.setLatticeValue(map,5,Map.BULLET);
            Map.setLatticeValue(map,5,Map.FOOD);
            //角色第一步存入历史记录中
            HistoryRecord.getHistory().add(map.getMap().get(Role.index));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }

    public static void main(String[] args) {
        Map map = initRun(10, 10);
        Scanner input = new Scanner(System.in);
        String info;
        while (true) {
            Map.printfMap(map);
            System.out.println();
            System.out.println("请输入你的命令：");
            info = input.next();
            Move.roleMove(getInfo(info),map);
        }
    }

    private static int getInfo(String input) {
        String info = input.toUpperCase();
        switch (info) {
            case "UP":return Move.UP;
            case "DOWN":return Move.DOWN;
            case "LEFT":return Move.LEFT;
            case "RIGHT":return Move.RIGHT;
            case "SHOOTING":return Move.SHOOTING;
            case "CHECKSTATE":Role.printfRole();return -2;
            case "HISTORY" : HistoryRecord.printfHistory();return -2;
            default: return -1;
        }
    }

    @Test
    public void test() {

    }
}
